import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '名称',
    align:"center",
    dataIndex: 'name'
   },
  //  {
  //   title: '通道类型',
  //   align:"center",
  //   dataIndex: 'channelType',
  //   customRender: ({ text }) => {
  //     return render.renderDict(text, 'channel_type');
  //   },
  //  },
   {
    title: '出入类型',
    align:"center",
    dataIndex: 'accessType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'accessType');
    },
   },
   {
    title: '门',
    align:"center",
    dataIndex: 'doorName',
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'memo'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "名称",
      field: 'name',
      component: 'JInput',
      //colProps: {span: 6},
 	},
	{
      label: "出入类型",
      field: 'accessType',
      component: 'JDictSelectTag',
      componentProps:{
        dictCode:"accessType",
        stringToNumber: true,
      }
      
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入名称!'},
          ];
     },
  },
  {
    label: '出入类型',
    field: 'accessType',
    component: 'JDictSelectTag',
    componentProps:{
         dictCode:"accessType",
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择类型!'},
          ];
     },
 },
 {
    label: '门',
    field: 'doorId',
    component: 'JDictSelectTag',
    componentProps:{
         dictCode:"ac_door,name,id",
         stringToNumber: true,
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择门!'},
          ];
     },
 },
  // {
  //   label: '通道类型',
  //   field: 'channelType',
  //   component: 'JDictSelectTag',
  //   componentProps:{
  //     dictCode:"channel_type",
  //     stringToNumber: true,
  //   },
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: true, message: '请选择类型!'},
  //         ];
  //    },
  // },
  {
    label: '描述',
    field: 'memo',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '名称',order: 0,view: 'text', type: 'string',},
  channelType: {title: '通道类型',order: 1,view: 'number', type: 'number',},
  memo: {title: '描述',order: 2,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}


export const acPersonChannelColumns:BasicColumn[] = [
  {
   title: '学/工号',
   align:"center",
   dataIndex: 'code',
   width:150
  },
  {
   title: '姓名',
   align:"center",
   dataIndex: 'name',
   width:150
  },
  {
   title: '部门',
   align:"center",
   dataIndex: 'departmentId_dictText',
   width:200
  },
];

export const acPersonChannelSearchFormSchema: FormSchema[] = [
  {
      label: "学/工号",
      field: 'code',
      component: 'Input',
      //colProps: {span: 6},
  },
  {
      label: "姓名",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
  },
 {
   label: '所在部门',
   field: 'departmentId',
   component: 'JSelectDept',
   componentProps:{
     isRadioSelection:true,
   }
 },
  
  
];

/** 通道关联设备列表
 */
export const channelDevColumns: BasicColumn[] = [
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'deviceName',
   width:150
  },
  {
   title: '设备类型',
   align:"center",
    width:150,
   dataIndex: 'deviceType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'deviceType');
   },
  },
  {
   title: '在线状态',
   align:"center",
   dataIndex: 'isOnline',
    width:80,
   customRender: ({ text }) => {
     return !text?"":(text=='0'?'离线':'在线');
   }
   }
];

//通道关联设备查询数据
export const channelDevSearchFormSchema: FormSchema[] = [
  {
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      colProps: {span: 6},
  },
  {
      label: "设备类型",
      field: 'deviceType',
      component: 'Input',
      colProps: {span: 6},
      defaultValue:1,
      show:false
  }

];


//设备查询数据
export const devSearchFormSchema: FormSchema[] = [
  {
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      colProps: {span: 6},
  },
  {
      label: "设备类型",
      field: 'deviceType',
      component: 'Input',
      colProps: {span: 6},
      defaultValue:1,
      show:false
  },
  {
    label: "通道",
    field: 'channelNotNull',
    component: 'Input',
    colProps: {span: 6},
    defaultValue:1,
    show:false
}
];

export const devColumns:BasicColumn[] = [
  {
   title: '设备编码',
   align:"center",
   dataIndex: 'deviceCode'
  },
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'deviceName'
  },
  {
   title: '设备标识码',
   align:"center",
   dataIndex: 'deviceSn'
  },
  {
   title: '设备类型',
   align:"center",
   dataIndex: 'deviceType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'deviceType');
   },
  },
  {
   title: '设备地址',
   align:"center",
   dataIndex: 'deviceIp'
  },
];
